<?php
class RegisterController extends BaseController {
	
	/**
	 * Display the sign up form
	 */
	public function index()
	{
		return View::make('register.index');
	}
	
	/**
	 * Accept the POST from sign up form
	 */
	public function store()
	{
		$validation = new Cribbb\Services\Validators\User;
		
		if($validation->passes())
		{	
			$this->user->create(
				array('email' => Input::get('email'), 'password' => Hash::make(Input::get('password')))
			);
		
			return Redirect::route('users.index')
				->with('flash', 'The new user has been created');
		}
		
		return Redirect::route('register.index')
			->withInput()
			->withErrors($validation->getErrors());
	}
 
}